﻿#region Copyright © 2013 Miracle Business Solutions
// All rights are reserved. Reproduction or transmission in whole or in part,
// any form or by any means, electronic, mechanical or otherwise, is prohibited
// without the prior written consent of the copyright owner.
// 
// Document:	RRLoader\RRloader.cs
// Creation Date:	11/11/2013
// Last Edit:		11/11/2013
// Author:		Moreno Sint Hill
#endregion

using System;
using System.Windows.Forms;
using JetBrains.Annotations;
using Styx.CommonBot.Routines;
using Styx.Plugins;

namespace RRLoader
{
    /// <summary>
    /// A Routine Reloader
    /// </summary>
    [UsedImplicitly]
    public class RRLoader : HBPlugin
    {
        /// <summary>
        /// To prevent the reload to fail
        /// </summary>
        internal static ICombatRoutine Backup;
        /// <summary>
        /// Just to launch the interface
        /// </summary>
        private Form _newtempui;

        #region Overrides of HBPlugin

        /// <summary>
        /// Called everytime the engine pulses.
        /// </summary>
        public override void Pulse()
        {
            //Magic White Space is not allowed
        }

        /// <summary>
        /// The name of this plugin.
        /// </summary>
        public override string Name
        {
            get { return @"RRLoader - A Routine Reloader"; }
        }

        /// <summary>
        /// The author of this plugin.
        /// </summary>
        public override string Author
        {
            get { return @"Mirabis"; }
        }

        /// <summary>
        /// The version of the plugin.
        /// </summary>
        public override Version Version
        {
            get { return new Version(1, 1); }
        }

        /// <summary>
        /// The text of the button if the plugin wants it. [Default: "Settings"]
        /// </summary>
        public override string ButtonText
        {
            get { return @"Reload"; }
        }
        
        /// <summary>
        /// Does this plugin want a button? If set to true, the button in the plugin manager will be enabled. [Default: false]
        /// </summary>
        public override bool WantButton
        {
            get { return true; }
        }
        
        /// <summary>
        /// Called when the user presses the button while having this plugin selected. The plugin can start a thread, show a form, or just do what the hell it wants.
        /// </summary>
        public override void OnButtonPress()
        {
            if (_newtempui == null || _newtempui.IsDisposed || _newtempui.Disposing) _newtempui = new GUI();
            if (_newtempui != null || _newtempui.IsDisposed) _newtempui.ShowDialog();
            base.OnButtonPress();
        }
        #endregion
    }
}
